package com.wfuhui.modules.oms.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wfuhui.modules.oms.entity.AppointEntity;
import com.wfuhui.modules.oms.service.AppointService;
import com.wfuhui.common.utils.PageUtils;
import com.wfuhui.common.utils.Query;
import com.wfuhui.common.utils.R;




/**
 * 预约
 * 

 */
@RestController
@RequestMapping("/oms/appoint")
public class AppointController {
	@Autowired
	private AppointService appointService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("mall:appoint:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<AppointEntity> appointList = appointService.queryList(query);
		int total = appointService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(appointList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("mall:appoint:info")
	public R info(@PathVariable("id") Integer id){
		AppointEntity appoint = appointService.queryObject(id);
		
		return R.ok().put("appoint", appoint);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("mall:appoint:save")
	public R save(@RequestBody AppointEntity appoint){
		appointService.save(appoint);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("mall:appoint:update")
	public R update(@RequestBody AppointEntity appoint){
		appointService.update(appoint);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("mall:appoint:delete")
	public R delete(@RequestBody Integer[] ids){
		appointService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
